/*
 * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 
 * use this file except in compliance with the License. You may obtain a copy 
 * of the License at 
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0 
 *   
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
 * License for the specific language governing permissions and limitations 
 * under the License.
 * 
 */
package org.go.matchers;

import org.go.trigger.TriggerKey;
import org.go.util.Key;
import org.go.work.WorkKey;

/**
 * Matches on the complete key being equal (both name and group). 
 *  
 * @author jhouse
 */
public class EverythingMatcher<T extends Key> implements Matcher<T> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 6231257816680746980L;

	/**
	 * Create an EverythingMatcher that matches all jobs.
	 */
	public static EverythingMatcher<WorkKey> allJobs() {
		return new EverythingMatcher<WorkKey>();
	}

	/**
	 * Create an EverythingMatcher that matches all triggers.
	 */
	public static EverythingMatcher<TriggerKey> allTriggers() {
		return new EverythingMatcher<TriggerKey>();
	}

	protected EverythingMatcher() {
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null)
			return false;

		return obj.getClass().equals(getClass());
	}

	@Override
	public int hashCode() {
		return getClass().getName().hashCode();
	}

	@Override
	public boolean isMatch(T key) {
		return true;
	}
}
